package com.example.designpattern.proxy.jdk;


import com.example.designpattern.proxy.staticProxy.MySubject;
import com.example.designpattern.proxy.staticProxy.RealSubject;

import java.lang.reflect.Proxy;


public class JdkProxyTest {
    public static void main(String[] args) {
        MySubject mySubject = new RealSubject();
        MyInvocationHandler myInvocationHandler = new MyInvocationHandler(mySubject);
        MySubject proxy = (MySubject) Proxy.newProxyInstance(
                mySubject.getClass().getClassLoader(),
                mySubject.getClass().getInterfaces(),
                myInvocationHandler);
        proxy.doSomething();
        System.out.println(proxy.fun());
    }
}
